﻿using Jay.Sc2.Bof.Lib.State;

namespace Jay.Sc2.Bof.Lib.Action.Terran
{
	public abstract class ActionUpgradeFromStarportTechLab : ActionUpgradeFromTerran
	{
		public ActionUpgradeFromStarportTechLab(int researchTime, int minerals, int gas) : base(researchTime, minerals, gas) { }

		public override TerranState.TerranProductionBuilding GetProductionBuilding(TerranState state) { return state.StarportTechLab; }

		public override IAction[,] Requirements
		{
			get
			{
				if (m_Requirements == null)
				{
					m_Requirements = new IAction[,] { 
						{ ActionProduceTechLabOnStarport.Instance }, 
						{ ActionSwitchTechLabFromFactoryToStarport.Instance }, 
						{ ActionSwitchTechLabFromBarracksToStarport.Instance }, 
					};
				}
				return m_Requirements;
			}
		}
	}
	public class ActionUpgradeCorvidReactor : ActionUpgradeFromStarportTechLab
	{
		public static ActionUpgradeCorvidReactor Instance = new ActionUpgradeCorvidReactor();
		public ActionUpgradeCorvidReactor() : base(110, 150, 150) { }
		public override TerranState.TerranUpgrade GetUpgrade(TerranState state) { return state.CorvidReactor; }
		public override string EventName { get { return "ActionResearchedCorvidReactor"; } }
	}
	public class ActionUpgradeCaduceusReactor : ActionUpgradeFromStarportTechLab
	{
		public static ActionUpgradeCaduceusReactor Instance = new ActionUpgradeCaduceusReactor();

		public ActionUpgradeCaduceusReactor() : base(80, 100, 100) { }

		public override TerranState.TerranUpgrade GetUpgrade(TerranState state) { return state.CaduceusReactor; }
		public override string EventName { get { return "ActionResearchedCaduceusReactor"; } }
	}
	public class ActionUpgradeDurableMaterials : ActionUpgradeFromStarportTechLab
	{
		public static ActionUpgradeDurableMaterials Instance = new ActionUpgradeDurableMaterials();

		public ActionUpgradeDurableMaterials() : base(110, 150, 150) { }

		public override TerranState.TerranUpgrade GetUpgrade(TerranState state) { return state.DurableMaterials; }
		public override string EventName { get { return "ActionResearchedDurableMaterials"; } }
		public override bool IsInvalid(IBuildOrder bo)
		{
			TerranState state = bo.State as TerranState;
			return base.IsInvalid(bo) || (state.Factory.Total + state.FactoryReactor.Total + state.FactoryTechLab.Total == 0);
		}
	}
	public class ActionUpgradeSeekerMissile : ActionUpgradeFromStarportTechLab
	{
		public static ActionUpgradeSeekerMissile Instance = new ActionUpgradeSeekerMissile();

		public ActionUpgradeSeekerMissile() : base(110, 150, 150) { }

		public override TerranState.TerranUpgrade GetUpgrade(TerranState state) { return state.SeekerMissile; }
		public override string EventName { get { return "ActionResearchedSeekerMissile"; } }
		public override bool IsInvalid(IBuildOrder bo)
		{
			TerranState state = bo.State as TerranState;
			return base.IsInvalid(bo) || state.FusionCore.Total == 0;
		}
		public override bool HaveTechnology(IBuildOrder bo)
		{
			TerranState state = bo.State as TerranState;
			return base.HaveTechnology(bo) && state.FusionCore.Count > 0;
		}
	}
	public class ActionUpgradeCloakingField : ActionUpgradeFromStarportTechLab
	{
		public static ActionUpgradeCloakingField Instance = new ActionUpgradeCloakingField();

		public ActionUpgradeCloakingField() : base(110, 200, 200) { }
		public override TerranState.TerranUpgrade GetUpgrade(TerranState state) { return state.CloakingField; }
		public override string EventName { get { return "ActionResearchedCloakingField"; } }
	}
}
